//
//  ViewController.m
//  DemoExceptionHandler
//
//  Created by chenzm on 2018/9/7.
//  Copyright © 2018年 chenzm. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
//    [self exceptionHandlerTest1];
//
//    [self exceptionHandlerTest2];
    
    [self exceptionHandlerTest3];
}



///异常处理测试1
-(void)exceptionHandlerTest1{
    //1、ios崩溃【数组越界】
    NSArray *array= @[@"tom",@"xxx",@"ooo"];
    [array objectAtIndex:5];

}
///异常处理测试2
-(void)exceptionHandlerTest2{
    //2、用来制造一些异常【不存在string的方法】
    [self performSelector:@selector(string) withObject:nil afterDelay:2.0];
}

///异常处理测试3
-(void)exceptionHandlerTest3{
    //3、信号量
    int list[2]={1,2};
    int *p = list;
    //[奔溃位置]导致SIGABRT的错误，因为内存中根本就没有这个空间，哪来的free，就在栈中的对象而已
    free(p);
    p[1] = 5;
}




- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
